package ah.szxy;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 启动类
 *
 * @author caohaiyang
 * @create 2020-09-10 下午 03:23
 */
@SpringBootApplication
@EnableDiscoveryClient
@RefreshScope // 表示配置文件更新后可以重新加载
@RestController
public class ConfigServiceApplication {

    public static void main(String[] args) {
        SpringApplication.run(ConfigServiceApplication.class, args);
    }

//    @Value("${user.name}")
//    private String userName;
//    @Value("${user.age}")
//    private String userAge;
//
//    @GetMapping("/config/get")
//    public ResponseEntity getConfig() {
//        return ResponseEntity.ok(String.format("获取配置信息 : userName = %s, userAge = %s", this.userName, this.userAge));
//    }

    @Value("${gg.name}")
    private String ggName;
    @Value("${gg.age}")
    private String ggAge;

    @GetMapping("/gg/get")
    public ResponseEntity<String> getGG(){
        return ResponseEntity.ok(ggName + ":" + ggAge);
    }

}